$(document).ready(function() {	

    $('.dialog_chk').click(function(e) {
        e.preventDefault();
		
        var id = $(this).attr('rel');
        
        var maskHeight = $(document).height();
        var maskWidth = $(window).width();
	
        $('#mask').css({
            'width': maskWidth,
            'height': maskHeight,
            'margin-left': -maskWidth/2,
            'margin-top': -maskHeight/2
        });

        var left = 0;
        var top  = 0;
        var winWidth = $(window).width();
        var winHeight = $(window).height();
        var dialogHeight = $(id).height();
        var dialogWidth  = $(id).width();
              
        $(id).css('top',  top + winHeight/2 - dialogHeight/2);
        $(id).css('left', left + winWidth/2 - dialogWidth/2);
	
        $(id).fadeIn(2000);
        
        $('#mask').fadeIn(1000);	
        $('#mask').fadeTo("slow",0.8);
	
    });
	
    $('.window .close, .close-source').click(function (e) {
        e.preventDefault();
		
        $('#mask').hide();
        $('.window').hide();
    });		
	
    $('#mask').click(function () {
        $(this).hide();
        $('.window').hide();
    });	
	
});